package lumis.content.core;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import lumis.portal.event.persistence.PortalEventEntityListener;
import lumis.portal.stability.StableMinor;


import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;

/**
 * A comment done for a content in a specific locale.
 * 
 * @stereotype entity
 * 
 * @version $Revision: 13082 $ $Date: 2011-05-27 16:03:12 -0300 (Fri, 27 May 2011) $
 * @since 4.2.0
 */
@StableMinor(version = "6.0", sinceVersion = "4.2")
@Entity
@Table(name="lum_ContentComment")
@GenericGenerator(name="portal-guid", strategy="lumis.portal.dao.hibernate.GuidGenerator")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@EntityListeners(value=PortalEventEntityListener.class)
@SuppressWarnings("serial")
public class ContentComment implements Serializable
{
	private String id;
	private String createdBy;
	private Date createdDateTime;
	private String commentText;
	private ContentLocale contentLocale;
	
	// -- Property Methods -- //
	
	@Id @GeneratedValue(generator="portal-guid")
	String getId()
	{
		return id;
	}
	void setId(String id)
	{
		this.id = id;
	}
	
	/**
	 * Returns the identifier of the principal that created this object.
	 * @return the principal identifier.
	 * @since 4.2.0
	 */
	public String getCreatedBy()
	{
		return createdBy;
	}
	
	/**
	 * Sets the principal that created this object.
	 * @param createdBy the principal identifier.
	 * @since 4.2.0
	 */
	public void setCreatedBy(String createdBy)
	{
		this.createdBy = createdBy;
	}
	
	/**
	 * Returns the date-time this comment was created.
	 * @return the date-time this comment was created.
	 * @since 4.2.0
	 */
	public Date getCreatedDateTime()
	{
		return createdDateTime;
	}
	
	/**
	 * Returns the date-time this comment was created.
	 * @param createdDateTime the date-time this comment was created.
	 * @since 4.2.0
	 */
	public void setCreatedDateTime(Date createdDateTime)
	{
		this.createdDateTime = createdDateTime;
	}
	
	/**
	 * Returns this comment's text.
	 * @return this comment's text.
	 * @since 4.2.0
	 */
	public String getCommentText()
	{
		return commentText;
	}
	
	/**
	 * Sets this comment's text.
	 * @param commentText the text to set.
	 * @since 4.2.0
	 */
	public void setCommentText(String commentText)
	{
		this.commentText = commentText;
	}
	
	/**
	 * Returns the {@link ContentLocale} this comment belongs to.
	 * @return the contentLocale.
	 * @since 4.2.0
	 */
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="contentLocaleId")
	public ContentLocale getContentLocale()
	{
		return contentLocale;
	}
	
	void setContentLocale(ContentLocale contentLocale)
	{
		this.contentLocale = contentLocale;
	}
}